#ifndef __IOT_FAN_CLOUD_MQTT_H__
#define __IOT_FAN_CLOUD_MQTT_H__

#include "cmsis_os2.h"


#define CONFIG_APP_LIFETIME 60 // seconds

#define CONFIG_QUEUE_TIMEOUT (5 * 1000)


typedef enum {
    en_msg_invalid = 0,
    en_msg_cmd,
    en_msg_report,
    en_msg_conn,
    en_msg_disconn
} en_msg_type_t;

typedef struct {
    char* request_id;
    char* payload;
} cmd_t;

typedef struct {
    int temp;
    int hum;
    int someone;
} report_t;

typedef struct {
    en_msg_type_t msg_type;
    union {
        cmd_t cmd;
        report_t report;
    } msg;
} app_msg_t;

typedef struct {
    osMessageQueueId_t app_msg;
    int connected;
    int led;
    int motor;
} app_cb_t;

extern app_cb_t g_app_cb;


/* MQTT连接华为云任务 */
int AgricultureCloudTask(void);


#endif

